package com.yoo.ons.view

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.drawable.Animatable
import android.util.AttributeSet
import android.widget.ImageView
import com.yoo.ons.R

@SuppressLint("AppCompatCustomView")
class LoadingView @JvmOverloads constructor(
        context: Context,
        attrs: AttributeSet? = null
) : ImageView(context, attrs) {
    init {
        setImageResource(R.drawable.animlist_loading)
    }

    override fun onDetachedFromWindow() {
        super.onDetachedFromWindow()
        (drawable as? Animatable)?.stop()
    }


    override fun onAttachedToWindow() {
        super.onAttachedToWindow()
        (drawable as? Animatable)?.start()
    }
}